﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ProjectCore.Application;
using ProjectCore.Domain.Model.Entity;

namespace ProjectCore.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AdminController : ControllerBase
    {
        private readonly IAppAdmin appAdmin;
        public AdminController(IAppAdmin _appAdmin)
        {
            appAdmin = _appAdmin;
        }
        /// <summary>
        /// 管理员显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ActionResult> GetAdmins()     
        {
            List<Admin> admins =await appAdmin.GetAdmins();
            return Ok(new { data = admins });
        }
        /// <summary>
        /// 管理员添加
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult> Add(Admin admin)
        {
            int n =await appAdmin.Add(admin);
            
            return Ok(n);
        }
    }
}
